Skip to content

fix(batch): publish only fully initialized batches - #455

Open
ubettigole wants to merge 1 commit into
abettigole/cancel_batch_resolutionfrom
abettigole/idempotent_batch_creation
Open

fix(batch): publish only fully initialized batches#455
ubettigole wants to merge 1 commit into
abettigole/cancel_batch_resolutionfrom
abettigole/idempotent_batch_creation

Conversation

@ubettigole

@ubettigole ubettigole commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Prevent partially initialized batches from becoming visible to downstream processing or dependency analysis.
New batches are first persisted in the Creating state. The batch controller then creates the batch’s reverse-index row, registers it with each dependency, and transitions it to Created only after structural initialization succeeds. Request-log and speculate publication happen only after that transition.

Retries continue to mint fresh batch IDs. Failed attempts may leave unpublished Creating or Created batches behind, but these attempts remain inert; metrics track their creation so a cleanup job can be added later if necessary.

Test Plan

Unit tests

Issues

@ubettigole
ubettigole marked this pull request as ready for review July 29, 2026 00:40
@ubettigole
ubettigole requested review from a team, behinddwalls and sbalabanov as code owners July 29, 2026 00:40
@ubettigole
ubettigole force-pushed the abettigole/idempotent_batch_creation branch from 3c288dd to ebe1008 Compare July 31, 2026 01:02
@ubettigole
ubettigole force-pushed the abettigole/idempotent_batch_creation branch from ebe1008 to d361e46 Compare July 31, 2026 01:04
@ubettigole ubettigole changed the title feat(batch): make creation resumable feat(batch): gate publication on batch readiness Jul 31, 2026
@ubettigole
ubettigole force-pushed the abettigole/idempotent_batch_creation branch from d361e46 to 5f05d6a Compare July 31, 2026 06:27
@ubettigole ubettigole changed the title feat(batch): gate publication on batch readiness fix(batch): publish only fully initialized batches Jul 31, 2026
}

// initializeBatch creates the reverse-index structure and marks a Creating batch ready for publication.
func (c *Controller) initializeBatch(ctx context.Context, batch entity.Batch) (entity.Batch, error) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we rename to populateBatch as we already created i guess?

func (c *Controller) initializeBatch(ctx context.Context, batch entity.Batch) (entity.Batch, error) {
batchDependent := entity.BatchDependent{
BatchID: batch.ID,
Dependents: []string{},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use the conflict.Analyzer.all for now here to populate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants